
#ifndef ELF_H
#define ELF_H

//#include <sys/stat.h>
//#include <sys/types.h>
//#include <unistd.h>
//#include <fcntl.h>
#define EI_NIDENT (16)

struct Elf32_Ehdr
{
  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
  unsigned short  	e_type;			/* Object file type */
  unsigned short	e_machine;		/* Architecture */
  unsigned int  	e_version;		/* Object file version */
  unsigned int  	e_entry;		/* Entry point virtual address */
  unsigned int  	e_phoff;		/* Program header table file offset */
  unsigned int  	e_shoff;		/* Section header table file offset */
  unsigned int  	e_flags;		/* Processor-specific flags */
  unsigned short	e_ehsize;		/* ELF header size in bytes */
  unsigned short	e_phentsize;		/* Program header table entry size */
  unsigned short	e_phnum;		/* Program header table entry count */
  unsigned short	e_shentsize;		/* Section header table entry size */
  unsigned short	e_shnum;		/* Section header table entry count */
  unsigned short	e_shstrndx;		/* Section header string table index */
};

struct Elf64_Ehdr
{
  unsigned char e_ident[EI_NIDENT];     /* Magic number and other info */
  unsigned short    e_type;                 /* Object file type */
  unsigned short    e_machine;              /* Architecture */
  unsigned int      e_version;              /* Object file version */
  unsigned long long     e_entry;                /* Entry point virtual address */
  unsigned long long     e_phoff;                /* Program header table file offset */
  unsigned long long     e_shoff;                /* Section header table file offset */
  unsigned int      e_flags;                /* Processor-specific flags */
  unsigned short    e_ehsize;               /* ELF header size in bytes */
  unsigned short    e_phentsize;            /* Program header table entry size */
  unsigned short    e_phnum;                /* Program header table entry count */
  unsigned short    e_shentsize;            /* Section header table entry size */
  unsigned short    e_shnum;                /* Section header table entry count */
  unsigned short    e_shstrndx;             /* Section header string table index */
};

struct Elf64_Shdr
{
  unsigned int    sh_name;                /* Section name (string tbl index) */
  unsigned int    sh_type;                /* Section type */
  unsigned long long   sh_flags;               /* Section flags */
  unsigned long long   sh_addr;                /* Section virtual addr at execution */
  unsigned long long   sh_offset;              /* Section file offset */
  unsigned long long   sh_size;                /* Section size in bytes */
  unsigned int    sh_link;                /* Link to another section */
  unsigned int    sh_info;                /* Additional section information */
  unsigned long long   sh_addralign;           /* Section alignment */
  unsigned long long   sh_entsize;             /* Entry size if section holds table */
} ;

struct Elf64_Dyn
{
  long long  d_tag;                  /* Dynamic entry type */
  union
    {
      unsigned long long d_val;                /* Integer value */
      unsigned long long d_ptr;                 /* Address value */
    } d_un;
} ;

struct Elf64_Phdr
{
  unsigned int    p_type;                 /* Segment type */
  unsigned int    p_flags;                /* Segment flags */
  unsigned long long     p_offset;               /* Segment file offset */
  unsigned long long    p_vaddr;                /* Segment virtual address */
  unsigned long long    p_paddr;                /* Segment physical address */
  unsigned long long   p_filesz;               /* Segment size in file */
  unsigned long long   p_memsz;                /* Segment size in memory */
  unsigned long long   p_align;                /* Segment alignment */
} ;

/* Legal values for p_type (segment type).  */

#define PT_NULL         0               /* Program header table entry unused
 */     
#define PT_LOAD         1               /* Loadable program segment */
#define PT_DYNAMIC      2               /* Dynamic linking information */

/* Legal values for d_tag (dynamic entry type).  */

#define DT_NULL         0               /* Marks end of dynamic section */
#define DT_NEEDED       1               /* Name of needed library */
#define DT_PLTRELSZ     2               /* Size in bytes of PLT relocs */
#define DT_PLTGOT       3               /* Processor defined value */
#define DT_HASH         4               /* Address of symbol hash table */
#define DT_STRTAB       5               /* Address of string table */
#define DT_SYMTAB       6               /* Address of symbol table */




#endif

